<?php


$nome  =  $_POST["nome"];
$senha =  $_POST["senha"];

if(($nome && $senha) != null){
    require 'conexao.php';
    
   $pesquisa = mysql_query("select * from login where nome = '".$nome."'"/*,$con*/);
          
   if (mysql_num_rows($pesquisa) == 0){
         header("location: ../view/viewErro.php?erro=4");} 
   
        while($row = mysql_fetch_object($pesquisa)){
           
            if ($row->senha == $senha){
                
            session_start("logado");
            $_SESSION['usuario'] = $nome;
            $_SESSION['funcao'] = $row->funcao;
             header("location: /site/view/principal.php");
            }
           
            else{              header("location: ../view/viewErro.php?erro=2");}
                
            
            
        } 
       

}
 else {
 header("location: ../view/viewErro.php?erro=1");  
}
mysql_free_result($pesquisa);
?>